﻿using System;
using RaytracerLib.MathLib;
using YAXLib;
using RaytracerLib.Rays;
using System.Diagnostics;

namespace RaytracerLib.Cameras
{
    public class PerspectiveCamera : PlaneCamera
    {
        public PerspectiveCamera(Vector3 a_right, Vector3 a_up) :
            base(a_right, a_up)
        {
            Name = "Perspective camera";
        }

        internal override CameraRay CreateRay(Vector2 a_uv)
        {
            Vector3 dir = Forward * MinimalPlaneDistant +
                Up * (m_viewport_height * (0.5 - a_uv.Y)) +
                Right * (m_viewport_width * (-0.5 + a_uv.X));

            return new CameraRay(Scene, Pos + dir, dir.Normalized);
        }
    }
}